Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add command to change CWD to current buffer's directory #6616

Closed

Conversation

ksdrar
Copy link

@ksdrar ksdrar commented Apr 6, 2023

No description provided.

@the-mikedavis
Copy link
Member

Duplicate of #3523

@the-mikedavis the-mikedavis marked this as a duplicate of #3523 Apr 6, 2023
@ksdrar ksdrar closed this Apr 8, 2023
@ksdrar ksdrar deleted the change-cwd-to-buffer-directory branch April 8, 2023 16:05
@ksdrar
Copy link
Author

ksdrar commented Apr 8, 2023

I was checking out the other pull request and thought it would be cool to have a $parent variable for the :cd command. So, I added it to the change_current_directory function in typed.rs. But, I'm not sure if this is the right way to add variables to commands. What do you think?

    let dir = {
        let arg = args
            .first()
            .context("target directory not provided")?
            .trim();

        if arg == "$parent" {
            doc!(cx.editor)
                .path()
                .and_then(|path| path.parent())
                .expect("Current buffer has no path or parent")
                .to_path_buf()
        } else {
            helix_core::path::expand_tilde(arg.as_ref())
        }
    };

@the-mikedavis
Copy link
Member

That seems too hacky to me. Initial support for variables is started in #3393

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants